Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Migrations not working on a fresh DatoCMS instance as a result of mismatched IDs #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bazottie
Copy link
Member

@bazottie bazottie commented Jan 8, 2025

Fixes several previous migrations relying on non-existent hardcoded IDs when creating a new project.
Updating previous migrations is not supposed to happen, however, no migration logic is changed.
It now relies on the API to find the right IDs using the corresponding label.

How to reproduce

  1. Follow "Getting started guide" from main on a personal DatoCMS account
  2. Upon running npx datocms migrations:run --destination=start --fast-fork at the corresponding step, expect an error

Example of a related error
(saved during debugging, this is not the first error to show up, but they are all similar)

Running migration "1730405111_linkRecords.ts"... failed!

----
Error: PUT https://site-api.datocms.com/item-types/EkWwcYfPQSGXskAZKO_tTg: 404 Not Found

[
  {
    "id": "302048",
    "type": "api_error",
    "attributes": {
      "code": "NOT_FOUND",
      "details": {}
    }
  }
]

I inferred the itemTypes for page and home_page from inspecting an existing DatoCMS instance that uses Head Start, please check if this is correct.

Changes

  • Updates references to non existent IDs with API calls to find the correct ID in a new instance
  • Adds error handling for finding menuItems since it now relies on finding IDs in a list

How to test

  1. Remove the start environment if it was created when attempting to reproduce the error
    1. If testing without reproducing, simply follow getting started guide
  2. Run npx datocms migrations:run --destination=start --fast-fork
  3. Migrations should succeed

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@bazottie bazottie added the bug Something isn't working label Jan 8, 2025
@bazottie bazottie changed the title FIX: Migrations not working on a fresh DatoCMS instance as a result of mismatched ID's fix: Migrations not working on a fresh DatoCMS instance as a result of mismatched ID's Jan 8, 2025
@bazottie bazottie changed the title fix: Migrations not working on a fresh DatoCMS instance as a result of mismatched ID's fix: Migrations not working on a fresh DatoCMS instance as a result of mismatched IDs Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant